#define LUMINANCE	0.465

uniform float fLuminance;
uniform sampler2D frame;

const float MiddleGray = 0.35;
const float WhiteCutoff = 0.9;

varying vec2 TexCoord;

void main(void)
{
	vec3 color = texture2D(frame, TexCoord).rgb;
	vec3 brightColor = max(color - vec3(LUMINANCE, LUMINANCE, LUMINANCE), 0.0);
	float bright = dot(brightColor, 1.0);
	bright = smoothstep(0.0, 0.5, bright);
	gl_FragColor = vec4(mix(0.0, color, bright), 1.0);
}
